package com.qu.waibao.baidu.openim;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.mobileim.YWAPI;
import com.alibaba.mobileim.YWIMKit;
import com.alibaba.mobileim.aop.Pointcut;
import com.alibaba.mobileim.aop.custom.IMConversationListUI;
import com.alibaba.mobileim.conversation.YWConversation;
import com.qu.waibao.AppConfig;
import com.qu.waibao.R;

/**
 * @描述 describe  456648
 * @作者 Administrator
 * @创建时间 2018/8/21 8:35
 * @邮箱 1123599561@qq.com
 */
public class ConversationListUICustomSample extends IMConversationListUI {
    public ConversationListUICustomSample(Pointcut pointcut) {
        super(pointcut);
    }

    @Override
    public View getCustomConversationListTitle(final Fragment fragment,
                                               final Context context, LayoutInflater inflater) {
        //TODO 重要：必须以该形式初始化customView---［inflate(R.layout.**, new RelativeLayout(context),false)］------，以让inflater知道父布局的类型，否则布局xml**中定义的高度和宽度无效，均被默认的wrap_content替代
        FrameLayout customView = (FrameLayout) inflater
                .inflate(R.layout.commen_top_layout, new RelativeLayout(context),false);
        TextView title = (TextView) customView.findViewById(R.id.tv_title);
        final YWIMKit mIMKit = YWAPI.getIMKitInstance(AppConfig.getString("userid"), AppConfig.APP_KEY);
        title.setText("我的消息");
        if(TextUtils.isEmpty(AppConfig.getString("userid"))){
            title.setText("未登录");
        }

        LinearLayout backButton = (LinearLayout) customView.findViewById(R.id.ll_back);
        backButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                fragment.getActivity().finish();
            }
        });
        customView.findViewById(R.id.iv_publish).setVisibility(View.GONE);
        return customView;
    }

}
